#ifndef __DRV_L2_SW_I2C_H__
#define __DRV_L2_SW_I2C_H__

#include "driver_l1.h"
#include "drv_l1_gpio.h"

#define _DRV_L2_SW_I2C	_DRV_L1_GPIO

typedef struct drv_l2_sw_i2c_ctl_s
{
	GPIO_ENUM		clk_port;
	IO_DRV_LEVEL	clk_drv;
	GPIO_ENUM		sda_port;
	IO_DRV_LEVEL	sda_drv;
	INT32U			timeout;
	INT32U			clock_rate;
	INT8U			slave_addr;
} drv_l2_sw_i2c_ctl_t;

#define SW_I2C_PULSE_DELAY			1
#define SW_I2C_INTER_BYTE_DELAY		30
#define SW_I2C_STOP_DELAY			50

extern void drv_l2_sw_i2c_init(drv_l2_sw_i2c_ctl_t *ctl);
extern INT32S drv_l2_sw_i2c_read(drv_l2_sw_i2c_ctl_t *ctl, INT8U *buf, INT32U len);
extern INT32S drv_l2_sw_i2c_write(drv_l2_sw_i2c_ctl_t *ctl, INT8U *buf, INT32U len);
extern void sw_i2c_use_sem_lock(void);
extern void sw_i2c_use_sem_unlock(void);

#endif //__DRV_L2_SW_I2C_H__
